package com.spa.application.service.admin;

import com.spa.application.command.admin.ShopUserAddCommand;
import com.spa.application.command.admin.ShopUserDelCommand;
import com.spa.application.dto.PageResult;
import com.spa.application.dto.admin.ShopUserDTO;
import com.spa.application.dto.admin.ShopUserExportDTO;
import com.spa.application.query.admin.ShopUserQuery;
import com.spa.domain.service.ShopService;
import com.spa.domain.service.ShopUserService;
import com.spa.infrastructure.enums.dict.base.WhetherTypeEnum;
import com.spa.infrastructure.mapper.ShopUserMapperStruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class ShopUserApplicationService {

    @Autowired
    private ShopUserService shopUserService;

    @Autowired
    private ShopService shopService;

    public void add(ShopUserAddCommand command) {
        shopUserService.addShopUser(command, WhetherTypeEnum.$1);
    }

    public void del(ShopUserDelCommand command) {
        shopUserService.delShopUser(command);
    }

    public PageResult<ShopUserDTO> page(ShopUserQuery query) {
        return ShopUserMapperStruct.INSTANCE.entity2Dto4Page(shopUserService.page(ShopUserMapperStruct.INSTANCE.query2Condition(query)));
    }

    public List<ShopUserExportDTO> list(ShopUserQuery query) {
        return ShopUserMapperStruct.INSTANCE.entity2ShopExportDto(shopUserService.allList(query));
    }
}
